import VueRouter from "vue-router";
import Home from "@/pages/Home";
import About from "@/pages/About";
import Message from "@/pages/Message";
import News from "@/pages/News";
import Detail from "@/pages/Detail";
const router = new VueRouter({
    mode:"history",
    routes: [
        {
            path: '/home',
            component: Home,
            children:[
                {
                    path:'news',
                    component:News
                },
                {
                    path:'message',
                    component:Message,
                    children:[
                        {
                            name:'xiangqing',
                            path:'detail/:id',
                            component:Detail,
                            /*props:{a:900}*//*第一种写法 props的值为对象,该对象中所有的key-value的组合最终的偶传给Datail组件作为props*/
                            /*props:true*//*第二种写法是布尔值 true 默认传递的是params参数*/
                            props(r){
                               return{
                                   id:r.params.id,
                                   title:r.query.title,
                                   content:r.query.content
                               }
                            }
                        }
                    ]

                }
            ]
        },
        {
            path: '/about',
            component: About
        },
        {
            path:'/*',
            redirect:'/about'
        }
    ]
})
export default router